package com.cutJar.core;

import com.cmd.core.CMD;
import com.cmd.exception.CMDException;
import com.cmd.exception.CMDNullException;
import com.conf.log.LOG;
import com.conf.log.impl.LogImpl;
import com.cutJar.Exception.ResourceNullException;
import com.cutJar.util.Resource;

/**
 * <b>步骤一  : 运行jar 生成class</b>
 * <p>
 * 描述:<br>
 * 调试程序
 * @author 威 
 * <br>2018年3月30日 下午9:04:13 
 * @since 1.0
 */
public class FirstStep {
	/**
	 * 这里用一句话描述这个方法的作用
	 * <p>	 
	 * @param jrePath jre bin文件全路径
	 * @param jarName 所调试的java-jar名称
	 * void
	 * @see
	 * @since 1.0
	 */
	public void doStart (String jrePath, String jarName){
		String batPath = null;			//bat路径
		String jarPath = null;			//jar路径
		String resultPath = null;		//class.txt输出路径
		try {
			batPath = Resource.getResurceToString("bat/JarClassData.bat");
			jarPath = Resource.getResurceToString(jarName+".jar");
			resultPath = Resource.getResurceToString("pre/class.txt");
		} catch (ResourceNullException e1) {
			LogImpl.getInstance().log(LOG.ERROR, e1.getMessage());
		}
		try {
			doStrat(jarPath, resultPath, batPath, jrePath);
		} catch (CMDException e) {
			LogImpl.getInstance().log(LOG.ERROR, e.getMessage());
		}
	}
	
	/**
	 * @param jarPath		启动的jar全路径
	 * @param resultPath	class.txt全路径
	 * @param batPath		bat全路径
	 * @param jrePath		jre全路径
	 * void
	 * @throws CMDException 
	 *
	 */
	public void doStrat(String jarPath, String resultPath, String batPath, String jrePath) throws CMDException{
		try {
			new CMD().start().bat(batPath).arg(jrePath).arg(jarPath).arg(resultPath).exet();
		} catch (CMDNullException e) {
			e.printStackTrace();
		}
	}
}

